<?php

class AjaxController extends Zend_Controller_Action {
    
    function init()
    {
        $this->initView();
        Zend_Loader::loadClass('Lesson');
        Zend_Loader::loadClass('User');
        Zend_Loader::loadClass('Group');
        Zend_Loader::loadClass('Zend_Json');
        
        $this->view->baseUrl = $this->_request->getBaseUrl();
        $this->view->user = Zend_Auth::getInstance()->getIdentity();
       
    }
    
    public function getlessonAction(){
        $id = $this->_request->getParam('id'); 
        $item = new Lesson();
        $return = $item->getRow($id);
        
        $user = new User();
        $UserInfo = $user->getUserInfo($return['teacher_id']);
        $return['teacher_name'] = $UserInfo['first_name'].' '.$UserInfo['last_name'];
        
        $group = new Group();
        $return['group_name'] = $group->getGroupName($return['studygroup_id']);
        
        $return['start_time'] = substr($return['start_time'],0,5);
        $return['end_time'] = substr($return['end_time'],0,5);
        
        echo Zend_Json::encode($return);
    }
}  
?>
